﻿

create proc [timer].[RemoveTimerFile]
@FileName nvarchar(450),
@UserID int
as
begin
	declare @errorMsg nvarchar(150),
			@logDate datetime2(7)

	if @FileName is null
	begin
		set @errorMsg = '@FileName is null or empty.'
		goto WithError
	end

	begin tran

	delete	[timer].hlpTimer
	where	[FileName] = @FileName
			and [UserID] = @UserID
							
	commit

	return 0

WithError:
	if @@TRANCOUNT != 0
	begin
		rollback tran
	end
	RAISERROR
    (@errorMsg,
    10, -- Severity.
    1, -- State.
    @UserID, -- First substitution argument.
    @FileName); -- Second substitution argument. 
	return -1 
end